package com.java.syun.pool;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;

@RestController
public class TestController {

    @Resource
    private MyDynamicThreadPool dynamicThreadPool;

    @Resource
    private ThreadPoolExecutor dtpExecutor;

    @RequestMapping("/execute")
    public void execute(){
        System.out.println("提交任务");
        dynamicThreadPool.execute(new MyRunnable());
        dynamicThreadPool.print();
    }

    @RequestMapping("/dtp")
    public void dtp(){
        dtpExecutor.execute(new MyRunnable());
        System.out.println("核心线程数：" + dtpExecutor.getCorePoolSize() + " " +"最大线程数：" + dtpExecutor.getMaximumPoolSize()
                +" " + "阻塞队列数：" + dtpExecutor.getQueue().size()  +" " + "活跃线程数：" + dtpExecutor.getActiveCount());
    }
}
